﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BangleCMS.Model;
using BangleCMS.BLL;

public partial class System_WebsideConfig_LeftModify : BasePage
{
    #region 属性

    /// <summary>
    /// Id
    /// </summary>
    private int Id
    {
        get
        {
            return ViewState["Id"] == null ? 0 : Convert.ToInt32(ViewState["Id"]);
        }
        set
        {
            ViewState["Id"] = value;
        }
    }

    /// <summary>
    /// Action
    /// </summary>
    private string Action
    {
        get
        {
            return ViewState["Action"] == null ? "Add" : ViewState["Action"].ToString();
        }
        set
        {
            ViewState["Action"] = value;
        }
    }

    #endregion

    #region 加载
    protected void Page_Load(object sender, EventArgs e)
    {
        //检验用户权限
        //base.CheckUserPermission("001002");
        if (!IsPostBack)
        {
            //加载数据
            GetDate();
        }
    }
    #endregion

    #region 加载数据

    private void GetDate()
    {
        this.txt_LeftPhone.Text = GetConfigValue("LeftPhone");
    }


    private string GetConfigValue(string ConfigKey)
    {
        try
        {
            web_config model = new web_config();
            web_configBLL bll = new web_configBLL();
            model = bll.GetModel(ConfigKey);

            if (model == null)
            {
                return "";
            }
            else
            {
                return model.ConfigValue;
            }
        }
        catch (Exception ex)
        {
            return "";
        }
    }

    #endregion

    #region 提交
    protected void btn_Submit_Click(object sender, EventArgs e)
    {
        Button btn_Submit = (Button)sender;
        string CommandName = btn_Submit.CommandName;


        web_configBLL bll = new web_configBLL();
        if (CommandName == "LeftPhone")
        {
            #region 修改网站名称
            try
            {
                web_config model = new web_config();
                model = bll.GetModel("LeftPhone");
                model.ConfigValue = this.txt_LeftPhone.Text.Trim();

                bool isOk = bll.Update(model);
                if (isOk)
                {
                    base.Alert("操作成功！");
                }
                else
                {
                    base.Alert("操作失败！");
                }
            }
            catch (Exception ex)
            {
                base.Alert("操作失败！");
                return;
            }
            #endregion
        }
    }
    #endregion
}
